var t,
  e = require("@/utils/jump"),
  a = (t = require("../../config/page")) && t.__esModule ? t : { default: t },
  o = require("@/utils/report");
Component({
  options: { multipleSlots: !0, addGlobalClass: !0 },
  properties: {
    extClass: { type: String, value: "" },
    background: {
      type: String,
      value: "rgba(255, 255, 255, 1)",
      observer: "_showChange",
    },
    backgroundColorTop: { type: String, value: "rgba(255, 255, 255, 0)" },
    color: { type: String, value: "rgba(0, 0, 0, 1)" },
    title: { type: String, value: "" },
    back: { type: Boolean, value: !0 },
    home: { type: Boolean, value: !1 },
    iconTheme: { type: String, value: "black" },
    delta: { type: Number, value: 1 },
    position: { type: Boolean, value: !1 },
    titleColor: { type: String, value: "rgba(0, 0, 0, 0.9)" },
    titleSize: { type: String, value: "34rpx" },
    titleFont: { type: String, value: "500" },
    isCustomBackFunc: { type: Boolean, value: !1 },
    isSearch: { type: Boolean, value: !1 },
  },
  created: function () {
    this.getSystemInfo();
  },
  attached: function () {
    this.setStyle();
  },
  data: {},
  pageLifetimes: {
    show: function () {
      getApp().globalSystemInfo.ios && (this.getSystemInfo(), this.setStyle());
    },
  },
  methods: {
    setStyle: function () {
      var t = getApp().globalSystemInfo,
        e = t.statusBarHeight,
        a = t.navBarHeight,
        o = t.capsulePosition,
        i = getApp().globalSystemInfo,
        n = i.navBarExtendHeight,
        r = i.ios,
        s = i.windowWidth,
        g = this.data,
        l = g.back,
        h = g.home,
        u = g.title,
        c = g.isSearch,
        p = s - o.right,
        d = s - o.left,
        f = [
          "color: ".concat(this.data.color),
          "background: ".concat(this.data.background),
          "height:".concat(a + n, "px"),
          "padding-top:".concat(e, "px"),
          "padding-right:".concat(d, "px"),
          "padding-bottom:".concat(n, "px"),
          "background-size: 100% 100%",
        ].join(";"),
        v = "";
      (v =
        (l && !h) || (!l && h) || (!l && !h && c) || (!l && !h && !c && !u)
          ? [
              "width:".concat(o.width, "px"),
              "height:".concat(o.height, "px"),
            ].join(";")
          : (l && h) || u
            ? [
                "width:".concat(o.width, "px"),
                "height:".concat(o.height, "px"),
                "margin-left:".concat(p, "px"),
              ].join(";")
            : ["width:auto", "margin-left:0px"].join(";")),
        this.setData({
          navigationbarinnerStyle: f,
          navBarLeft: v,
          navBarHeight: a,
          capsulePosition: o,
          navBarExtendHeight: n,
          ios: r,
        });
    },
    _showChange: function () {
      this.setStyle();
    },
    back: function () {
      this.data.isCustomBackFunc
        ? this.triggerEvent("backFunc", {})
        : getCurrentPages().length > this.data.delta
          ? wx.navigateBack({ delta: this.data.delta })
          : wx.reLaunch({ url: a.default.PAGE_INDEX });
    },
    home: function () {
      wx.reLaunch({ url: a.default.PAGE_INDEX });
    },
    search: function () {
      (0, o.report)("fpage_search_show", {}),
        (0, e.navigateTo)(a.default.PAGE_RECOMMEND_SEARCH, {});
    },
    getSystemInfo: function () {
      var t = getApp();
      if (t.globalSystemInfo && !t.globalSystemInfo.ios)
        return t.globalSystemInfo;
      var e,
        a = wx.getSystemInfoSync(),
        o = !!(a.system.toLowerCase().search("ios") + 1);
      try {
        if (
          null ===
          (e = wx.getMenuButtonBoundingClientRect
            ? wx.getMenuButtonBoundingClientRect()
            : null)
        )
          throw "getMenuButtonBoundingClientRect error";
        if (!(e.width && e.top && e.left && e.height))
          throw "getMenuButtonBoundingClientRect error";
      } catch (t) {
        var i = 0,
          n = 96;
        "android" === a.platform
          ? ((i = 8), (n = 96))
          : "devtools" === a.platform
            ? (i = o ? 5.5 : 7.5)
            : ((i = 4), (n = 88)),
          a.statusBarHeight ||
            (a.statusBarHeight = a.screenHeight - a.windowHeight - 20),
          (e = {
            bottom: a.statusBarHeight + i + 32,
            height: 32,
            left: a.windowWidth - n - 10,
            right: a.windowWidth - 10,
            top: a.statusBarHeight + i,
            width: n,
          }),
          console.log("error", t),
          console.log("rect", e);
      }
      var r = 0;
      return (
        a.statusBarHeight
          ? ((r = (function () {
              var t = e.top - a.statusBarHeight;
              return a.statusBarHeight + 2 * t + e.height;
            })()),
            (a.navBarExtendHeight = o ? 4 : 0))
          : ((a.statusBarHeight = a.screenHeight - a.windowHeight - 20),
            (r = 2 * (e.top - a.statusBarHeight) + e.height),
            (a.statusBarHeight = 0),
            (a.navBarExtendHeight = 0)),
        (a.navBarHeight = r),
        (a.capsulePosition = e),
        (a.ios = o),
        (t.globalSystemInfo = a),
        a
      );
    },
  },
});
